from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import (
    DishCategoryViewSet, DishViewSet,
    VdjDishCategoryViewSet, VdjDishViewSet,
    ChefMenuViewSet
)

# 客户端路由 (普通用户/厨师)
client_router = DefaultRouter()
client_router.register(r'dish-categories', DishCategoryViewSet, basename='dish-category')
client_router.register(r'dishes', DishViewSet, basename='dish')

# 管理端路由
admin_router = DefaultRouter()
admin_router.register(r'dish-categories', VdjDishCategoryViewSet, basename='admin-dish-category')
admin_router.register(r'dishes', VdjDishViewSet, basename='admin-dish')

# 消费端路由 (无需认证或仅需基础认证)
consumer_router = DefaultRouter()
consumer_router.register(r'chefs/(?P<chef_id>\d+)/menu', ChefMenuViewSet, basename='consumer-chef-menu')


urlpatterns = [
    # 客户端API (厨师个人管理)
    path('client/', include(client_router.urls)),
    
    # 管理端API
    path('admin/', include(admin_router.urls)),
    
    # 消费端API (用户查看)
    path('consumer/', include(consumer_router.urls)),
    
    # 客户端特殊端点

    # 图片上传端点
    path('dishes/upload-image/', 
         DishViewSet.as_view({'post': 'upload_image'}), 
         name='dish-upload-image'),
    
    path('client/chef/dishes/<int:pk>/add-image/', 
         DishViewSet.as_view({'post': 'add_image'}), 
         name='dish-add_image'),
    # 我的菜品列表
    path('dishes/mine/', 
         DishViewSet.as_view({'get': 'mine'}), 
         name='dish-mine'),

    # 添加厨师自己的菜品列表端点
    path('client/chef/dishes/', DishViewSet.as_view({
        'get': 'list',  # 获取菜品列表
        'post': 'create'  # 创建新菜品
    }), name='client-chef-dishes'),

    path('client/chef/del-dishes/<int:pk>/', DishViewSet.as_view({
        'delete': 'destroy'  # 删除菜品信息
    }), name='client-del-dishes'),
    
    # 菜品图片获取接口
    path(
        'client/chef/dishes/<int:pk>/images/',
        DishViewSet.as_view({'get': 'get_images'}),
        name='dish-images'
    ),
    # 添加分类列表端点
    path('client/chef/dish-categories/', DishCategoryViewSet.as_view({'get': 'list'}), name='client-chef-categories'),
]